In [1]:
import pandas as pd
import matplotlib.pyplot as plt
from matplotlib import style
style.use('ggplot')
%matplotlib inline
import plotly
import plotly.express as px
import plotly.graph_objects as go
import cufflinks as cf
import plotly.offline as pyo
from plotly.offline import init_notebook_mode,plot,iplot
import folium
plt.rcParams['figure.figsize']=12,8
In [2]:
pyo.init_notebook_mode(connected=False)
cf.go_offline()
In [3]:
df=pd.read_excel("Covid cases in India.xlsx",header=0)
df
Out[3]:
S. No. Name of State / UT Total Confirmed cases (Indian National) Total Confirmed cases ( Foreign National ) Cured Death
0 1 Andhra Pradesh 12 0 1 0
1 2 Chhattisgarh 6 0 0 0
2 3 Delhi 38 1 6 1
3 4 Gujarat 43 0 0 3
4 5 Haryana 16 14 11 0
5 6 Himachal Pradesh 4 0 0 1
6 7 Karnataka 20 0 3 2
7 8 Kerala 131 7 11 0
8 9 Madhya Pradesh 23 0 0 1
9 10 Maharashtra 144 3 15 4
10 11 Odisha 3 0 0 0
11 12 Puducherry 1 0 0 0
12 13 Punjab 29 0 0 1
13 14 Rajasthan 41 2 3 0
14 15 Tamil Nadu 32 3 1 1
15 16 Telengana 34 11 1 0
16 17 Chandigarh 7 0 0 0
17 18 Jammu and Kashmir 18 0 1 1
18 19 Ladakh 13 0 0 0
19 20 Uttar Pradesh 42 1 11 0
20 21 Uttarakhand 4 0 0 0
21 22 West Bengal 11 0 0 1
22 23 Bihar 7 0 0 1
23 24 Mizoram 1 0 0 0
24 25 Goa 6 0 0 0
25 26 Manipur 1 0 0 0
In [4]:
df.drop("S. No.",axis=1,inplace=True)
In [5]:
df
Out[5]:
Name of State / UT Total Confirmed cases (Indian National) Total Confirmed cases ( Foreign National ) Cured Death
0 Andhra Pradesh 12 0 1 0
1 Chhattisgarh 6 0 0 0
2 Delhi 38 1 6 1
3 Gujarat 43 0 0 3
4 Haryana 16 14 11 0
5 Himachal Pradesh 4 0 0 1
6 Karnataka 20 0 3 2
7 Kerala 131 7 11 0
8 Madhya Pradesh 23 0 0 1
9 Maharashtra 144 3 15 4
10 Odisha 3 0 0 0
11 Puducherry 1 0 0 0
12 Punjab 29 0 0 1
13 Rajasthan 41 2 3 0
14 Tamil Nadu 32 3 1 1
15 Telengana 34 11 1 0
16 Chandigarh 7 0 0 0
17 Jammu and Kashmir 18 0 1 1
18 Ladakh 13 0 0 0
19 Uttar Pradesh 42 1 11 0
20 Uttarakhand 4 0 0 0
21 West Bengal 11 0 0 1
22 Bihar 7 0 0 1
23 Mizoram 1 0 0 0
24 Goa 6 0 0 0
25 Manipur 1 0 0 0
In [7]:
df['Total cases']=df['Total Confirmed cases (Indian National)']+df['Total Confirmed cases ( Foreign National )']
df
Out[7]:
Name of State / UT Total Confirmed cases (Indian National) Total Confirmed cases ( Foreign National ) Cured Death Total cases
0 Andhra Pradesh 12 0 1 0 12
1 Chhattisgarh 6 0 0 0 6
2 Delhi 38 1 6 1 39
3 Gujarat 43 0 0 3 43
4 Haryana 16 14 11 0 30
5 Himachal Pradesh 4 0 0 1 4
6 Karnataka 20 0 3 2 20
7 Kerala 131 7 11 0 138
8 Madhya Pradesh 23 0 0 1 23
9 Maharashtra 144 3 15 4 147
10 Odisha 3 0 0 0 3
11 Puducherry 1 0 0 0 1
12 Punjab 29 0 0 1 29
13 Rajasthan 41 2 3 0 43
14 Tamil Nadu 32 3 1 1 35
15 Telengana 34 11 1 0 45
16 Chandigarh 7 0 0 0 7
17 Jammu and Kashmir 18 0 1 1 18
18 Ladakh 13 0 0 0 13
19 Uttar Pradesh 42 1 11 0 43
20 Uttarakhand 4 0 0 0 4
21 West Bengal 11 0 0 1 11
22 Bihar 7 0 0 1 7
23 Mizoram 1 0 0 0 1
24 Goa 6 0 0 0 6
25 Manipur 1 0 0 0 1
In [8]:
total_cases_overall=df['Total cases'].sum()
print('the total no of confimes cases till now in INDIA is',total_cases_overall)
the total no of confimes cases till now in INDIA is 729
In [9]:
df['Total Active cases']= df['Total cases']-(df['Cured']+df['Death'])
df
Out[9]:
Name of State / UT Total Confirmed cases (Indian National) Total Confirmed cases ( Foreign National ) Cured Death Total cases Total Active cases
0 Andhra Pradesh 12 0 1 0 12 11
1 Chhattisgarh 6 0 0 0 6 6
2 Delhi 38 1 6 1 39 32
3 Gujarat 43 0 0 3 43 40
4 Haryana 16 14 11 0 30 19
5 Himachal Pradesh 4 0 0 1 4 3
6 Karnataka 20 0 3 2 20 15
7 Kerala 131 7 11 0 138 127
8 Madhya Pradesh 23 0 0 1 23 22
9 Maharashtra 144 3 15 4 147 128
10 Odisha 3 0 0 0 3 3
11 Puducherry 1 0 0 0 1 1
12 Punjab 29 0 0 1 29 28
13 Rajasthan 41 2 3 0 43 40
14 Tamil Nadu 32 3 1 1 35 33
15 Telengana 34 11 1 0 45 44
16 Chandigarh 7 0 0 0 7 7
17 Jammu and Kashmir 18 0 1 1 18 16
18 Ladakh 13 0 0 0 13 13
19 Uttar Pradesh 42 1 11 0 43 32
20 Uttarakhand 4 0 0 0 4 4
21 West Bengal 11 0 0 1 11 10
22 Bihar 7 0 0 1 7 6
23 Mizoram 1 0 0 0 1 1
24 Goa 6 0 0 0 6 6
25 Manipur 1 0 0 0 1 1
In [10]:
df.style.background_gradient(cmap='Blues')
Out[10]:
Name of State / UT Total Confirmed cases (Indian National) Total Confirmed cases ( Foreign National ) Cured Death Total cases Total Active cases
0 Andhra Pradesh 12 0 1 0 12 11
1 Chhattisgarh 6 0 0 0 6 6
2 Delhi 38 1 6 1 39 32
3 Gujarat 43 0 0 3 43 40
4 Haryana 16 14 11 0 30 19
5 Himachal Pradesh 4 0 0 1 4 3
6 Karnataka 20 0 3 2 20 15
7 Kerala 131 7 11 0 138 127
8 Madhya Pradesh 23 0 0 1 23 22
9 Maharashtra 144 3 15 4 147 128
10 Odisha 3 0 0 0 3 3
11 Puducherry 1 0 0 0 1 1
12 Punjab 29 0 0 1 29 28
13 Rajasthan 41 2 3 0 43 40
14 Tamil Nadu 32 3 1 1 35 33
15 Telengana 34 11 1 0 45 44
16 Chandigarh 7 0 0 0 7 7
17 Jammu and Kashmir 18 0 1 1 18 16
18 Ladakh 13 0 0 0 13 13
19 Uttar Pradesh 42 1 11 0 43 32
20 Uttarakhand 4 0 0 0 4 4
21 West Bengal 11 0 0 1 11 10
22 Bihar 7 0 0 1 7 6
23 Mizoram 1 0 0 0 1 1
24 Goa 6 0 0 0 6 6
25 Manipur 1 0 0 0 1 1
In [11]:
# if we want to see only active cases
# .sum method is used to represent the data 
# to make the data good... use. to_frame
Total_active_cases=df.groupby('Name of State / UT')['Total Active cases'].sum().sort_values(ascending=False).to_frame()
In [12]:
Total_active_cases
Out[12]:
Total Active cases
Name of State / UT
Maharashtra 128
Kerala 127
Telengana 44
Rajasthan 40
Gujarat 40
Tamil Nadu 33
Uttar Pradesh 32
Delhi 32
Punjab 28
Madhya Pradesh 22
Haryana 19
Jammu and Kashmir 16
Karnataka 15
Ladakh 13
Andhra Pradesh 11
West Bengal 10
Chandigarh 7
Goa 6
Chhattisgarh 6
Bihar 6
Uttarakhand 4
Himachal Pradesh 3
Odisha 3
Manipur 1
Mizoram 1
Puducherry 1
In [13]:
# this works over on dataframe.. so make the dataframe of data first
Total_active_cases.style.background_gradient(cmap='Reds')
Out[13]:
Total Active cases
Name of State / UT
Maharashtra 128
Kerala 127
Telengana 44
Rajasthan 40
Gujarat 40
Tamil Nadu 33
Uttar Pradesh 32
Delhi 32
Punjab 28
Madhya Pradesh 22
Haryana 19
Jammu and Kashmir 16
Karnataka 15
Ladakh 13
Andhra Pradesh 11
West Bengal 10
Chandigarh 7
Goa 6
Chhattisgarh 6
Bihar 6
Uttarakhand 4
Himachal Pradesh 3
Odisha 3
Manipur 1
Mizoram 1
Puducherry 1

Graphical Representation of numerical data

In [15]:
#using pandas
df.plot(kind='bar',x='Name of State / UT',y='Total cases')
Out[15]:
<matplotlib.axes._subplots.AxesSubplot at 0x15fc850>
In [16]:
# using matplotlib

plt.bar(df['Name of State / UT'],df['Total cases'])
plt.xticks(rotation=60)
plt.show()
In [19]:
#using plotly
df.iplot(kind='bar',x='Name of State / UT',y='Total cases')
In [20]:
#plotly express

px.bar(df,x='Name of State / UT',y='Total cases')
In [21]:
#scatter using matplotlib
plt.scatter(df['Name of State / UT'],df['Total cases'])
plt.xticks(rotation=60)
plt.show()
In [22]:
#scatter plot using plotly

df.iplot(kind='scatter',x='Name of State / UT',y='Total cases',mode='markers+lines',title='my Graph',
         xTitle='Name of State / UT',yTitle='Total cases',colors='green',size=20)
In [23]:
# scatter plot using plotly express
px.scatter(df,x='Name of State / UT',y='Total cases')

Object oriented method for visualization

In [24]:
# matplotlib

fig=plt.figure(figsize=(12,8),dpi=200)  ## dpi=dots per inches, it can zoom the graph
axes=fig.add_axes([0,0,1,1])
axes.bar(df['Name of State / UT'],df['Total cases'])
plt.show()
In [25]:
#plotly
fig=go.Figure()
fig.add_trace(go.Bar(x=df['Name of State / UT'],y=df['Total cases']))   # add_trace= add layout
fig.update_layout(title='My Graph',xaxis=dict(title='Name of State / UT'),yaxis=dict(title='Total cases'))
In [26]:
#Map
indian_coordinate=pd.read_excel("Indian Coordinates.xlsx")
indian_coordinate
Out[26]:
Name of State / UT Latitude Longitude
0 Andaman And Nicobar 11.667026 92.735983
1 Andhra Pradesh 14.750429 78.570026
2 Arunachal Pradesh 27.100399 93.616601
3 Assam 26.749981 94.216667
4 Bihar 25.785414 87.479973
5 Chandigarh 30.719997 76.780006
6 Chhattisgarh 22.090420 82.159987
7 Dadra And Nagar Haveli 20.266578 73.016618
8 Delhi 28.669993 77.230004
9 Goa 15.491997 73.818001
10 Haryana 28.450006 77.019991
11 Himachal Pradesh 31.100025 77.166597
12 Union Territory of Jammu and Kashmir 33.450000 76.240000
13 Jharkhand 23.800393 86.419986
14 Karnataka 12.570381 76.919997
15 Kerala 8.900373 76.569993
16 Lakshadweep 10.562573 72.636867
17 Madhya Pradesh 21.300391 76.130019
18 Maharashtra 19.250232 73.160175
19 Manipur 24.799971 93.950017
20 Meghalaya 25.570492 91.880014
21 Mizoram 23.710399 92.720015
22 Nagaland 25.666998 94.116570
23 Orissa 19.820430 85.900017
24 Puducherry 11.934994 79.830000
25 Punjab 31.519974 75.980003
26 Rajasthan 26.449999 74.639981
27 Sikkim 27.333330 88.616647
28 Telengana 18.112400 79.019300
29 Tamil Nadu 12.920386 79.150042
30 Tripura 23.835404 91.279999
31 Uttar Pradesh 27.599981 78.050006
32 Uttarakhand 30.320409 78.050006
33 West Bengal 22.580390 88.329947
34 Union Territory of Ladakh 34.100000 77.340000
In [27]:
df_full=pd.merge(indian_coordinate,df,on='Name of State / UT')
df_full
Out[27]:
Name of State / UT Latitude Longitude Total Confirmed cases (Indian National) Total Confirmed cases ( Foreign National ) Cured Death Total cases Total Active cases
0 Andhra Pradesh 14.750429 78.570026 12 0 1 0 12 11
1 Delhi 28.669993 77.230004 38 1 6 1 39 32
2 Haryana 28.450006 77.019991 16 14 11 0 30 19
3 Karnataka 12.570381 76.919997 20 0 3 2 20 15
4 Kerala 8.900373 76.569993 131 7 11 0 138 127
5 Maharashtra 19.250232 73.160175 144 3 15 4 147 128
6 Punjab 31.519974 75.980003 29 0 0 1 29 28
7 Rajasthan 26.449999 74.639981 41 2 3 0 43 40
8 Telengana 18.112400 79.019300 34 11 1 0 45 44
9 Tamil Nadu 12.920386 79.150042 32 3 1 1 35 33
10 Uttar Pradesh 27.599981 78.050006 42 1 11 0 43 32
11 Uttarakhand 30.320409 78.050006 4 0 0 0 4 4
In [28]:
# tiles= types of map graohs

map=folium.Map(location=[20,70],zoom_start=4,tiles='Stamenterrain')

for lat,long,value,name in zip(df_full['Latitude'],df_full['Longitude'],df_full['Total cases'],df_full['Name of State / UT']):
    folium.CircleMarker([lat,long],radius=value*0.8,popup=('<strong>State</strong>: '+str(name).capitalize()+'<br>''<strong>Total Cases</strong>: ' + str(value)+ '<br>'),color='red',fill_color='red',fill_opacity=0.3).add_to(map)
              
In [29]:
map
Out[29]:

How COVID is rising Globally

In [30]:
dbd_india=pd.read_excel("per_day_cases.xlsx",parse_dates=True,sheet_name='India')
dbd_india
Out[30]:
Date Total Cases New Cases Days after surpassing 100 cases
0 2020-01-30 1 1 NaN
1 2020-01-31 1 0 NaN
2 2020-02-01 1 0 NaN
3 2020-02-02 2 1 NaN
4 2020-02-03 3 1 NaN
5 2020-02-04 3 0 NaN
6 2020-02-05 3 0 NaN
7 2020-02-06 3 0 NaN
8 2020-02-07 3 0 NaN
9 2020-02-08 3 0 NaN
10 2020-02-09 3 0 NaN
11 2020-02-10 3 0 NaN
12 2020-02-11 3 0 NaN
13 2020-02-12 3 0 NaN
14 2020-02-13 3 0 NaN
15 2020-02-14 3 0 NaN
16 2020-02-15 3 0 NaN
17 2020-02-16 3 0 NaN
18 2020-02-17 3 0 NaN
19 2020-02-18 3 0 NaN
20 2020-02-19 3 0 NaN
21 2020-02-20 3 0 NaN
22 2020-02-21 3 0 NaN
23 2020-02-22 3 0 NaN
24 2020-02-23 3 0 NaN
25 2020-02-24 3 0 NaN
26 2020-02-25 3 0 NaN
27 2020-02-26 3 0 NaN
28 2020-02-27 3 0 NaN
29 2020-02-28 3 0 NaN
30 2020-02-29 3 0 NaN
31 2020-03-01 3 0 NaN
32 2020-03-02 6 3 NaN
33 2020-03-03 9 3 NaN
34 2020-03-04 28 19 NaN
35 2020-03-05 30 2 NaN
36 2020-03-06 31 1 NaN
37 2020-03-07 34 3 NaN
38 2020-03-08 39 5 NaN
39 2020-03-09 43 4 NaN
40 2020-03-10 56 13 NaN
41 2020-03-11 62 6 NaN
42 2020-03-12 73 11 NaN
43 2020-03-13 82 9 NaN
44 2020-03-14 102 20 0.0
45 2020-03-15 113 11 1.0
46 2020-03-16 119 6 2.0
47 2020-03-17 142 23 3.0
48 2020-03-18 156 14 4.0
49 2020-03-19 194 38 5.0
50 2020-03-20 244 50 6.0
51 2020-03-21 271 27 7.0
In [31]:
dbd_italy=pd.read_excel("per_day_cases.xlsx",parse_dates=True,sheet_name='Italy')
dbd_korea=pd.read_excel("per_day_cases.xlsx",parse_dates=True,sheet_name='Korea')
dbd_wuhan=pd.read_excel("per_day_cases.xlsx",parse_dates=True,sheet_name='Wuhan')
In [32]:
#visualization of data of fpur countries
# using matplotlib

fig=plt.figure(figsize=(10,5),dpi=200)
axes=fig.add_axes([0.1,0.1,0.8,0.8])
axes.bar(dbd_india['Date'],dbd_india['Total Cases'],color='Blue')
axes.set_xlabel('Date')
axes.set_ylabel('Total cases')
axes.set_title('confirmed cases in INDIA')
plt.show()
In [33]:
# using plotly express                    as we can use plotly as well to show more graphs

fig=px.bar(dbd_india,x='Date',y='Total Cases',color='Total Cases',title='confirmed cases in INDIA')
fig.show()
In [34]:
fig=px.bar(dbd_italy,x='Date',y='Total Cases',color='Total Cases',title='confirmed cases in Italy')
fig.show()
fig=px.bar(dbd_korea,x='Date',y='Total Cases',color='Total Cases',title='confirmed cases in korea')
fig.show()
fig=px.bar(dbd_wuhan,x='Date',y='Total Cases',color='Total Cases',title='confirmed cases in wuhan')
fig.show()
In [35]:
#Plotly

dbd_india.iplot(kind='scatter',x='Date',y='Total Cases',mode='lines+markers')
In [36]:
#plotly graph_objects

fig=go.Figure()
fig.add_trace(go.Scatter(x=dbd_india['Date'],y=dbd_india['Total Cases'],mode='lines+markers'))
In [37]:
# subplot using Bar graph
In [38]:
from plotly.subplots import make_subplots
In [39]:
fig=make_subplots(
    rows=2,cols=2,
    specs=[[{"secondary_y":True},{"secondary_y":True}],[{"secondary_y":True},{"secondary_y":True}]],
    subplot_titles=("S.Korea","Italy","India","Wuhan"))

fig.add_trace(go.Bar(x=dbd_korea['Date'],y=dbd_korea['Total Cases'],
                    marker=dict(color=dbd_korea['Total Cases'],coloraxis="coloraxis")),1,1)

fig.add_trace(go.Bar(x=dbd_italy['Date'],y=dbd_italy['Total Cases'],
                    marker=dict(color=dbd_italy['Total Cases'],coloraxis="coloraxis")),1,2)

fig.add_trace(go.Bar(x=dbd_india['Date'],y=dbd_india['Total Cases'],
                    marker=dict(color=dbd_india['Total Cases'],coloraxis="coloraxis")),2,1)

fig.add_trace(go.Bar(x=dbd_wuhan['Date'],y=dbd_wuhan['Total Cases'],
                    marker=dict(color=dbd_wuhan['Total Cases'],coloraxis="coloraxis")),2,2)

fig.update_layout(coloraxis=dict(colorscale='Bluered_r'),showlegend=False,title_text="Total Cases in 4 Countries")

fig.update_layout(plot_bgcolor='rgb(230,230,230)')
In [40]:
# worldmap for corona Virus
In [41]:
df1=pd.read_csv("covid_19_data.csv",parse_dates=['Last Update'])
df1.head()
Out[41]:
SNo ObservationDate Province/State Country/Region Last Update Confirmed Deaths Recovered
0 1 01/22/2020 Anhui Mainland China 2020-01-22 17:00:00 1.0 0.0 0.0
1 2 01/22/2020 Beijing Mainland China 2020-01-22 17:00:00 14.0 0.0 0.0
2 3 01/22/2020 Chongqing Mainland China 2020-01-22 17:00:00 6.0 0.0 0.0
3 4 01/22/2020 Fujian Mainland China 2020-01-22 17:00:00 1.0 0.0 0.0
4 5 01/22/2020 Gansu Mainland China 2020-01-22 17:00:00 0.0 0.0 0.0
In [42]:
df1.rename(columns={'ObservationDate':'Date','Country/Region':'Country'},inplace=True)
df1.head()
Out[42]:
SNo Date Province/State Country Last Update Confirmed Deaths Recovered
0 1 01/22/2020 Anhui Mainland China 2020-01-22 17:00:00 1.0 0.0 0.0
1 2 01/22/2020 Beijing Mainland China 2020-01-22 17:00:00 14.0 0.0 0.0
2 3 01/22/2020 Chongqing Mainland China 2020-01-22 17:00:00 6.0 0.0 0.0
3 4 01/22/2020 Fujian Mainland China 2020-01-22 17:00:00 1.0 0.0 0.0
4 5 01/22/2020 Gansu Mainland China 2020-01-22 17:00:00 0.0 0.0 0.0
In [43]:
df1.query('Country=="India"')
Out[43]:
SNo Date Province/State Country Last Update Confirmed Deaths Recovered
430 431 01/30/2020 NaN India 2020-01-30 16:00:00 1.0 0.0 0.0
491 492 01/31/2020 NaN India 2020-01-31 23:59:00 1.0 0.0 0.0
547 548 02/01/2020 NaN India 2020-01-31 08:15:00 1.0 0.0 0.0
607 608 02/02/2020 NaN India 2020-02-02 06:03:08 2.0 0.0 0.0
672 673 02/03/2020 NaN India 2020-02-03 21:43:02 3.0 0.0 0.0
740 741 02/04/2020 NaN India 2020-02-03 21:43:02 3.0 0.0 0.0
810 811 02/05/2020 NaN India 2020-02-03 21:43:02 3.0 0.0 0.0
881 882 02/06/2020 NaN India 2020-02-03 21:43:02 3.0 0.0 0.0
954 955 02/07/2020 NaN India 2020-02-03 21:43:02 3.0 0.0 0.0
1026 1027 02/08/2020 NaN India 2020-02-03 21:43:02 3.0 0.0 0.0
1098 1099 02/09/2020 NaN India 2020-02-03 21:43:02 3.0 0.0 0.0
1171 1172 02/10/2020 NaN India 2020-02-03 21:43:02 3.0 0.0 0.0
1243 1244 02/11/2020 NaN India 2020-02-03 21:43:02 3.0 0.0 0.0
1316 1317 02/12/2020 NaN India 2020-02-03 21:43:02 3.0 0.0 0.0
1389 1390 02/13/2020 NaN India 2020-02-13 18:53:02 3.0 0.0 0.0
1463 1464 02/14/2020 NaN India 2020-02-13 18:53:02 3.0 0.0 0.0
1538 1539 02/15/2020 NaN India 2020-02-13 18:53:02 3.0 0.0 0.0
1613 1614 02/16/2020 NaN India 2020-02-16 07:43:02 3.0 0.0 3.0
1688 1689 02/17/2020 NaN India 2020-02-16 07:43:02 3.0 0.0 3.0
1763 1764 02/18/2020 NaN India 2020-02-16 07:43:02 3.0 0.0 3.0
1838 1839 02/19/2020 NaN India 2020-02-16 07:43:02 3.0 0.0 3.0
1915 1916 02/20/2020 NaN India 2020-02-16 07:43:02 3.0 0.0 3.0
1995 1996 02/21/2020 NaN India 2020-02-16 07:43:02 3.0 0.0 3.0
2079 2080 02/22/2020 NaN India 2020-02-16 07:43:02 3.0 0.0 3.0
2163 2164 02/23/2020 NaN India 2020-02-16 07:43:02 3.0 0.0 3.0
2248 2249 02/24/2020 NaN India 2020-02-16 07:43:02 3.0 0.0 3.0
2341 2342 02/25/2020 NaN India 2020-02-16 07:43:02 3.0 0.0 3.0
2438 2439 02/26/2020 NaN India 2020-02-16 07:43:02 3.0 0.0 3.0
2543 2544 02/27/2020 NaN India 2020-02-16 07:43:02 3.0 0.0 3.0
2650 2651 02/28/2020 NaN India 2020-02-16 07:43:02 3.0 0.0 3.0
2771 2772 02/29/2020 NaN India 2020-02-16 07:43:02 3.0 0.0 3.0
2895 2896 03/01/2020 NaN India 2020-02-16 07:43:02 3.0 0.0 3.0
3016 3017 03/02/2020 NaN India 2020-03-02 22:33:09 5.0 0.0 3.0
3162 3163 03/03/2020 NaN India 2020-03-02 22:33:09 5.0 0.0 3.0
3288 3289 03/04/2020 NaN India 2020-03-04 12:33:03 28.0 0.0 3.0
3451 3452 03/05/2020 NaN India 2020-03-05 13:53:03 30.0 0.0 3.0
3624 3625 03/06/2020 NaN India 2020-03-06 13:03:12 31.0 0.0 3.0
3825 3826 03/07/2020 NaN India 2020-03-07 18:13:27 34.0 0.0 3.0
4051 4052 03/08/2020 NaN India 2020-03-08 09:23:05 39.0 0.0 3.0
4308 4309 03/09/2020 NaN India 2020-03-09 09:13:17 43.0 0.0 3.0
4573 4574 03/10/2020 NaN India 2020-03-10 10:13:28 56.0 0.0 4.0
4781 4782 03/11/2020 NaN India 2020-03-11 22:13:12 62.0 1.0 4.0
4996 4997 03/12/2020 NaN India 2020-03-12 08:33:13 73.0 1.0 4.0
5277 5278 03/13/2020 NaN India 2020-03-11 20:00:00 82.0 2.0 4.0
5451 5452 03/14/2020 NaN India 2020-03-14 20:33:03 102.0 2.0 4.0
5699 5700 03/15/2020 NaN India 2020-03-15 18:20:18 113.0 2.0 13.0
In [44]:
df1.groupby('Date').sum()
Out[44]:
SNo Confirmed Deaths Recovered
Date
01/22/2020 741 555.0 17.0 28.0
01/23/2020 2829 653.0 18.0 30.0
01/24/2020 4305 941.0 26.0 36.0
01/25/2020 6490 1438.0 42.0 39.0
01/26/2020 9071 2118.0 56.0 52.0
01/27/2020 12342 2927.0 82.0 61.0
01/28/2020 15262 5578.0 131.0 107.0
01/29/2020 18711 6165.0 133.0 126.0
01/30/2020 23345 8235.0 171.0 143.0
01/31/2020 28675 9925.0 213.0 222.0
02/01/2020 35309 12038.0 259.0 284.0
02/02/2020 39798 16787.0 362.0 472.0
02/03/2020 44982 19881.0 426.0 623.0
02/04/2020 51135 23892.0 492.0 852.0
02/05/2020 56871 27636.0 564.0 1124.0
02/06/2020 61912 30818.0 634.0 1487.0
02/07/2020 67932 34392.0 719.0 2011.0
02/08/2020 73116 37121.0 806.0 2616.0
02/09/2020 78300 40151.0 906.0 3244.0
02/10/2020 83484 42763.0 1013.0 3946.0
02/11/2020 89936 44803.0 1113.0 4683.0
02/12/2020 95265 45222.0 1118.0 5150.0
02/13/2020 102009 60370.0 1371.0 6295.0
02/14/2020 108975 66887.0 1523.0 8058.0
02/15/2020 114600 69032.0 1666.0 9395.0
02/16/2020 120225 71226.0 1770.0 10865.0
02/17/2020 125850 73260.0 1868.0 12583.0
02/18/2020 131475 75138.0 2007.0 14352.0
02/19/2020 138966 75641.0 2122.0 16121.0
02/20/2020 144742 76199.0 2247.0 18177.0
02/21/2020 166698 76843.0 2251.0 18890.0
02/22/2020 173754 78599.0 2458.0 22886.0
02/23/2020 183005 78985.0 2469.0 23394.0
02/24/2020 201645 79570.0 2629.0 25227.0
02/25/2020 219255 80415.0 2708.0 27905.0
02/26/2020 245430 81397.0 2770.0 30384.0
02/27/2020 265965 82756.0 2814.0 33277.0
02/28/2020 301245 84124.0 2872.0 36711.0
02/29/2020 328321 86013.0 2941.0 39782.0
03/01/2020 360125 88371.0 2996.0 42716.0
03/02/2020 424974 90309.0 3085.0 45602.0
03/03/2020 477160 92844.0 3160.0 48229.0
03/04/2020 530480 95124.0 3254.0 51171.0
03/05/2020 602386 97886.0 3348.0 53797.0
03/06/2020 729932 101800.0 3460.0 55866.0
03/07/2020 873000 105836.0 3558.0 58359.0
03/08/2020 1050600 109835.0 3803.0 60695.0
03/09/2020 1165213 113582.0 3996.0 62512.0
03/10/2020 950999 118582.0 4262.0 64404.0
03/11/2020 1042740 125865.0 4615.0 67003.0
03/12/2020 1099701 128343.0 4720.0 68324.0
03/13/2020 1211755 145193.0 5404.0 70251.0
03/14/2020 1371492 156099.0 5819.0 72624.0
03/15/2020 1486467 167447.0 6440.0 76034.0
In [45]:
confirmed=df1.groupby('Date').sum()['Confirmed'].reset_index()
death=df1.groupby('Date').sum()['Deaths'].reset_index()
recovered=df1.groupby('Date').sum()['Recovered'].reset_index()
In [46]:
fig=go.Figure()
fig.add_trace(go.Scatter(x=confirmed['Date'],y=confirmed['Confirmed'],mode='lines+markers',name='Confirmed',line=dict(color='blue',width=2)))

fig.add_trace(go.Scatter(x=death['Date'],y=death['Deaths'],mode='lines+markers',name='Deaths',line=dict(color='red',width=2)))
fig.add_trace(go.Scatter(x=recovered['Date'],y=recovered['Recovered'],mode='lines+markers',name='Recovered',line=dict(color='green',width=2)))
fig.update_layout(margin={"r":0,"t":0,"l":0,"b":0})
In [47]:
df_confirmed=pd.read_csv("time_series_covid_19_confirmed.csv")
df_confirmed.rename(columns={'Country/Region':'Country'},inplace=True)
In [ ]:
 
In [48]:
df_latlong=pd.merge(df1,df_confirmed,on=['Country','Province/State'])
df_latlong.head()
Out[48]:
SNo Date Province/State Country Last Update Confirmed Deaths Recovered Lat Long ... 3/5/20 3/6/20 3/7/20 3/8/20 3/9/20 3/10/20 3/11/20 3/12/20 3/13/20 3/14/20
0 32 01/22/2020 Washington US 2020-01-22 17:00:00 1.0 0.0 0.0 47.4009 -121.4905 ... 0 0 0 0 0 267 366 442 568 572
1 70 01/23/2020 Washington US 2020-01-23 17:00:00 1.0 0.0 0.0 47.4009 -121.4905 ... 0 0 0 0 0 267 366 442 568 572
2 118 01/24/2020 Washington US 2020-01-24 17:00:00 1.0 0.0 0.0 47.4009 -121.4905 ... 0 0 0 0 0 267 366 442 568 572
3 159 01/25/2020 Washington US 2020-01-25 17:00:00 1.0 0.0 0.0 47.4009 -121.4905 ... 0 0 0 0 0 267 366 442 568 572
4 203 01/26/2020 Washington US 2020-01-26 16:00:00 1.0 0.0 0.0 47.4009 -121.4905 ... 0 0 0 0 0 267 366 442 568 572

5 rows × 63 columns

In [49]:
fig=px.density_mapbox(df_latlong,lat='Lat',lon='Long',hover_name='Province/State',hover_data=['Confirmed','Deaths','Recovered'],
                     animation_frame='Date',color_continuous_scale='Portland',radius=7,zoom=0,height=600)
fig.update_layout(title='Worldwide Corona Virus Cases')
fig.update_layout(mapbox_style="open-street-map",mapbox_center_lon=0)
fig.update_layout(margin={"r":0,"t":0,"l":0,"b":0})
In [ ]:
 
In [ ]:
 
In [ ]:
 
In [ ]:
 
In [ ]:
 
In [ ]:
 
In [ ]: